﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaleOnlineSystem.Admin.Controls
{
    public partial class ListComment : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {          
                if (!Page.IsPostBack)
                {
                    //Them du lieu vao cat 1

                    rpt_comment.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Comment1", " * ", "selectbycolumns");

                    rpt_comment.DataBind();
                }                    
        }

        protected void rpt_comment_ItemCommand(object source, RepeaterCommandEventArgs e)
        {           
                if (e.CommandName == "delete")
                {
                    string id = (e.CommandArgument.ToString());

                    DAL.DCollector.DBCollector.Instance.CallStored("callstored", "delete from tbl_Comment1 where Comment1_ID=" + id, false);

                    rpt_comment.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Comment1", " * ", "selectbycolumns");

                    rpt_comment.DataBind();
                }
                if (e.CommandName == "change")
                {
                    string id = (e.CommandArgument.ToString());

                    DAL.DCollector.DBCollector.Instance.CallStored("change_active_comment", id, false);

                    rpt_comment.DataSource = DAL.DCollector.DBCollector.Instance.StoredProcedureSelectByColumns("tbl_Comment1", " * ", "selectbycolumns");

                    rpt_comment.DataBind();
                }                 
        }
    }
}